<!--
 * @Author: gongjiuhui
 * @Date: 2022-04-21 16:34:36
 * @LastEditTime: 2022-05-13 11:45:40
 * @LastEditors: gong.jiuhui you@example.com
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \jk_one-stop_cloud_mobile_v1.0\src\views\apply\purchaseDetail.vue
-->
<template>
  <div class="purchaseDetail">
    <Navbar @eventGetHeight="getHeight" :appTitle="title" />
    <!--头部-->
    <div id="headdd" class="d-head">
      <div class="content">
        <div class="left">
          <div class="title">
            {{ $route.query.title }}
          </div>
          <div class="row">
            <span class="r-label">合同编号：</span>
            <span class="r-column">{{
              workOrderInfo.contractCode || "--"
            }}</span>
          </div>
          <div class="row">
            <span class="r-label">签订人：</span>
            <span class="r-column">{{
              workOrderInfo.signUserIdText || "--"
            }}</span>
          </div>
          <div class="status">{{ workOrderInfo.statusText }}</div>
        </div>
        <!--           ids="ERP_PURCHASE_CONTRACT" -->
        <imgStatus
          :flowStatus="workOrderInfo.flowStatus"
        ></imgStatus>
      </div>
    </div>

    <!-- taps-->
    <!--锚点选项卡-->
    <van-tabs v-model="active" scrollspy sticky :offset-top="runingHeight">
      <!--基本信息 -->
      <van-tab title="基本信息">
        <div class="otherTaps" :style="calssDD">
          <div class="title">
            <span class="icon"></span>
            <span class="content">基本信息</span>
          </div>
          <div class="content">
            <div class="row">
              <span class="r-label">合同名称：</span>
              <span class="r-column">{{
                workOrderInfo.contractName || "--"
              }}</span>
            </div>
            <div class="row">
              <span class="r-label">所属供应商：</span>
              <span class="r-column">{{
                workOrderInfo.supplierIdText || "--"
              }}</span>
            </div>
            <div class="row">
              <span class="r-label">合同金额：</span>
              <span class="r-column">{{
                numFormat(workOrderInfo.amount, 2)
              }}</span>
            </div>
            <div class="row">
              <span class="r-label tt">附件：</span>
              <span class="r-column" style="flex: 1;">
                <span v-if="workOrderInfo.attachment == ''">--</span>
                <upload
                  class="fileclass"
                  iconType="fj"
                  @fileChange="fileChange"
                  :fileIds="workOrderInfo.attachment"
                  :showUpload="false"
                ></upload>
              </span>
            </div>
          </div>
        </div>
      </van-tab>
      <!--基本信息 -->
      <van-tab title="收货记录">
        <div
          class="otherTaps"
          v-for="(
            item, index
          ) in workOrderInfo.erpPurchaseSignOrderItemInfoVoList"
          :key="index"
        >
          <div class="title">
            <span class="icon"></span>
            <span class="content">收货记录<span v-if="workOrderInfo.erpPurchaseSignOrderItemInfoVoList.length!=1">{{ index + 1 }}</span></span>
          </div>
          <div class="content">
            <div class="row">
              <span class="r-label">商品编号：</span>
              <span class="r-column">{{ item.goodsCode }} </span>
            </div>
            <div class="row">
              <span class="r-label">商品名称：</span>
              <span class="r-column">{{ item.goodsName }}</span>
            </div>
            <div class="row">
              <span class="r-label">需求到货日期：</span>
              <span class="r-column">{{ item.arrivalDate }}</span>
            </div>
            <div class="row">
              <span class="r-label">采购数量：</span>
              <span class="r-column">{{ item.purchaseNum }}</span>
            </div>
            <div class="row">
              <span class="r-label">已签收：</span>
              <span class="r-column">{{ item.signNum }}</span>
            </div>
            <div class="row">
              <span class="r-label">实际入库：</span>
              <span class="r-column">{{ item.warehousingNum }}</span>
            </div>
            <div class="row">
              <span class="r-label">待签收：</span>
              <span class="r-column">{{ item.signedNum }}</span>
            </div>
          </div>
        </div>
      </van-tab>
      <!--操作报工 -->
      <van-tab
        title="签收单"
        v-if="workOrderInfo.erpPurchaseSignOrderDealVoList&&workOrderInfo.erpPurchaseSignOrderDealVoList.length!=0"
      >
        <div
          class="otherTaps"
          v-for="(item, index) in workOrderInfo.erpPurchaseSignOrderDealVoList"
          :key="index"
           :style="(!showFLow&&workOrderInfo.erpPurchaseSignOrderDealVoList&&workOrderInfo.erpPurchaseSignOrderDealVoList.length!=0)?bottomHeight:''"

        >
          <div class="title">
            <span class="icon"></span>
            <span class="content">签收单<span v-if="workOrderInfo.erpPurchaseSignOrderDealVoList.length!=1">{{ index + 1 }}</span></span>
          </div>
          <div class="content">
            <div class="row">
              <span class="r-label">签收单号：</span>
              <span class="r-column">{{ item.receiptCode }}</span>
            </div>
            <div class="row">
              <span class="r-label">签收人：</span>
              <span class="r-column">{{ item.createBy }}</span>
            </div>
            <div class="row">
              <span class="r-label">签收时间：</span>
              <span class="r-column">{{ item.createTime }}</span>
            </div>
            <div class="row">
              <span class="r-label">签收种类：</span>
              <span class="r-column">{{ item.receiptGoodsType }}</span>
            </div>
            <div class="row">
              <span class="r-label">总签收数量：</span>
              <span class="r-column">{{ item.receiptNum }}</span>
            </div>
            <div class="row">
              <span class="r-label">状态：</span>
              <span class="r-column">{{ item.flowStatus }}</span>
            </div>
          </div>
        </div>
      </van-tab>

      <!--审批流程 -->
      <van-tab title="审批流程" v-if="workOrderInfo.flowInstId">
        <div class="otherTaps" :style="bottomHeight">
          <div class="title">
            <span class="icon"></span>
            <span class="content">审批流程</span>
          </div>
          <!--  ids="ERP_PURCHASE_CONTRACT" -->
          <Examine
            v-if="workOrderInfo.flowInstId"
            type="2"
            :id="workOrderInfo.flowInstId"
            ref="examine"
            :showTitle="false"
          />
        </div>
      </van-tab>
    </van-tabs>

    <!--提交按钮 -->
    <div
      class="search-bottom"
      v-if="
        $route.query.applyType == 'waiterDeal' &&
        workOrderInfo.flowStatus == 'RUNNING'
      "
    >
      <span class="btncancel" @click="cancel">拒绝</span>
      <span class="btnconfirm" @click="confirm">同意</span>
    </div>
  </div>
</template>

<script>
import { erpPurchaseContractQueryById } from "@/api/mobile.js";
import Navbar from "@/components/navBar/navBar_right";
import upload from "@/components/upload/upload";
import Examine from "@/components/examine";
import { numFormat } from "@/utils/util";
import imgStatus from "@/components/imgStatus/imgStatus";
import { getEnableOne } from "@/api/api";
export default {
  name: "recordDetail",
  components: { Navbar, upload, Examine, imgStatus },
  data() {
    return {
      bodyHeight:"",
      runingHeight: "",
      bottomHeight:"padding-bottom:1.5rem",
      calssDD: "",
      numFormat,
      parentId: "",
      tableData: [],
      workOrderInfo: {},
      reasonArr: [], //不合格原因
      title: "采购合同详情",
      tabList: [
        { name: "发货记录", value: "1" },
        { name: "开票记录", value: "2" },
        { name: "收款记录", value: "2" },
      ],
      active: 0,
      fileIds: "",
      showFLow:true,
    };
  },
  computed: {},
  mounted() {
    
  },
  created() {
    this.parentId = this.$route.query.id;
    this.getDetail();
    this.isShowFLow();
  },
  methods: {
     isShowFLow(){
       getEnableOne({ id: "ERP_PURCHASE_CONTRACT", type: "add" }).then((res) => {
        if (res.result && res.result == "false") {
          this.showFLow = false;
           
        } else {
          this.showFLow = true;
        
        }
      });   
     },
     getHeight(data) {
      this.bodyHeight=document.body.clientHeight;//屏幕高度
     
      if(this.bodyHeight>=736){
        this.bottomHeight="padding-bottom:2rem";
      }
      if(this.bodyHeight>=812){
         this.bottomHeight="padding-bottom:2.7rem";
      }
      if(this.bodyHeight>=896){
         this.bottomHeight="padding-bottom:3rem";
      }
      let topdd=this.GLOBAL.currentEnvironment ? '0' : '46'
      this.runingHeight =data+document.getElementById("headdd").offsetHeight+10;
      this.calssDD = "margin-top:" + (this.runingHeight - topdd) + "px";
    },
    cancel() {
      // approveType 1:同意 0:拒绝
      this.$router.push({
        path: "/approval",
        query: { approveType: 0, taskId: this.$route.query.taskId },
      });
    },
    confirm() {
      this.$router.push({
        path: "/approval",
        query: { approveType: 1, taskId: this.$route.query.taskId },
      });
    },
    fileChange(ids) {
      console.log(ids);
      this.formData.attachment = ids;
    },
    getDetail() {
      erpPurchaseContractQueryById({ id: this.parentId }).then((res) => {
        if (res.success) {
          if (res.result) {
            this.workOrderInfo = res.result;
          }
        } else {
          this.$toast(res.message);
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.purchaseDetail {
  height: 100vh;
  overflow-y: scroll;
  background: #ffffff;
  .d-head {
    position: fixed;
    width: 100%;
    padding: 0.16rem 0.16rem 0.16rem 0.16rem;
    background: #ffffff;
    z-index: 999;
    .status {
      display: inline-block;
      margin-top: 0.16rem;
      padding: 0.03rem 0.08rem;
      background: #edf6ff;
      border-radius: 0.02rem;
      font-size: 0.11rem;
      font-family: PingFang SC;
      font-weight: 400;
      color: #3774ac;
    }
    .content {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .left {
        width: 2.8rem;
        // border: 1px solid red;
        .title {
          font-size: 0.16rem;
          font-family: PingFang SC;
          font-weight: 500;
          color: #191f25;
          line-height: 0.22rem;

          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          -o-text-overflow: ellipsis;
        }
        .row {
          font-size: 0.14rem;
          font-family: PingFang SC;
          font-weight: 400;
          color: #888888;
          margin-top: 0.16rem;
          display: flex;
          .r-label {
            color: #888888;
          }
          .r-column {
            color: #191f25;
          }
        }
      }
      .right {
        // border: 1px solid red;
        width: 0.6rem;
        .rightImg {
          display: block;
          width: 0.55rem;
          height: 0.55rem;
          //   margin-left: 0.45rem;
          // border: 1px solid blue;
        }
      }
    }
  }

  .otherTaps {
    background: #ffffff;
    padding: 0.16rem;
    border-top: 0.1rem solid rgb(245, 245, 245);
    .title {
      padding-bottom: 0.1rem;
      border-bottom: 1px solid #eeeeee;
      .icon {
        display: inline-block;
        width: 0.03rem;
        height: 0.14rem;
        background: #1890ff;
      }
      .content {
        width: 0.63rem;
        height: 0.16rem;
        font-size: 0.16rem;
        font-family: PingFang SC;
        font-weight: bold;
        color: #191f25;
        line-height: 0.22rem;
        margin-left: 0.1rem;
      }
    }
    .content {
      .row {
        font-size: 0.14rem;
        font-family: PingFang SC;
        font-weight: 400;
        margin-top: 0.16rem;
        display: flex;
        .r-label {
          color: #888888;
          // width: 1.4rem;
        }
        .r-column {
          //   display: block;
          color: #191f25;
          // width: 100%;
          white-space: normal;
          word-break: break-all;
          word-wrap: break-word;

          //   border: 1px solid red;
          //    width: 1rem;
        }
      }
      .fhrow {
        display: flex;
        .fhImg {
          width: 0.55rem;
          height: 0.55rem;
          border-radius: 0.1rem;
        }
        .rt-column {
          width: 2.55rem;
          //   height: 2.55rem;
          margin-left: 0.2rem;
          .rt-title {
            font-size: 0.16rem;
            font-family: PingFang SC;
            font-weight: 500;
            color: #191f25;
            margin-bottom: 0.16rem;
          }
          .rt-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.23rem;
            .column {
              //    border: 1px solid red;
              width: 1.5rem;
              .column-t {
                font-size: 0.14rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #888888;
                display: block;
                width: 100%;
                margin-bottom: 0.03rem;
              }
              .column-c {
                font-size: 0.16rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #191f25;
                display: block;
                width: 100%;
              }
            }
          }
        }
      }
    }
  }
  .search-bottom {
    height: 0.5rem;
    width: 100%;
    background: #ffffff;
    // background: red;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0px;
    padding: 0.11rem;
    .btnconfirm {
      width: 1.72rem;
      height: 0.39rem;
      background: #1890ff;
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;
    }
    .btncancel {
      width: 1.72rem;
      height: 0.39rem;
      background: #f6f6f6;
      border: 0.01px solid rgba(25, 31, 37, 0.12);
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;
    }
  }
}
</style>
<style>
.van-tabs__line {
  background-color: #1890ff;
}
.van-tab--active {
  color: #1890ff;
}
</style>